﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using InventoryShell.ProductManagement.Product_Category;
using InventoryBusinessLogic.ProductManagmentDataContractLayer;

namespace InventoryShell.ProductManagement
{
    public partial class NewProduct : UserControl
    {
        bool IsExpanded = false;
        public Button btnAddNew;// = new Button();
        public NewProduct()
        {
            InitializeComponent();
            SetValuesToCategoryCombo();
        }

        private void SetValuesToCategoryCombo()
        {

            List<ProductCategoryType> categorList = new List<ProductCategoryType>();

            ProductCategoryType categoryType1 = new ProductCategoryType();
            categoryType1.CategoryName = "Choose";
            categoryType1.CategoryId = 0;
            categorList.Add(categoryType1);

            ProductCategoryType categoryType = new ProductCategoryType();
            categoryType.CategoryName = "  < Add New >  ";
            categoryType.CategoryId = 9999;
            categorList.Add(categoryType);

           

            BindingSource myBindingSource = new BindingSource();

            myBindingSource.DataSource = categorList;

            cmbProductCategory.DataSource = null;
            cmbProductCategory.DataSource = categorList;
            cmbProductCategory.DisplayMember = "CategoryName";
           cmbProductCategory.ValueMember = "CategoryId";

        }

        void btnAddNew_Click(object sender, EventArgs e)
        {
            throw new NotImplementedException();
        }


        //private void btnAddNew_Click(object sender, EventArgs e)
        //{
        //    CreateCategory frmCreateCategory = new CreateCategory();
        //    frmCreateCategory.Show();
        //}

        private void btnExpand_Click(object sender, EventArgs e)
        {
            if (!IsExpanded)
            {
                panelMainControls.Hide();
                panelProductGridView.Dock = DockStyle.Fill;
                IsExpanded = true;
                btnExpand.Text = "Hide";
            }
            else
            {
                panelMainControls.Show();
                panelProductGridView.Dock = DockStyle.Left;
                IsExpanded = false;
                btnExpand.Text = "View All";
            }
        }

        private void cmbProductCategory_SelectedValueChanged(object sender, EventArgs e)
        {
            if (cmbProductCategory.SelectedValue.ToString() == "9999")
            {
                CreateCategory frmCreateCategory = new CreateCategory();
                frmCreateCategory.Show();
                frmCreateCategory.StartPosition = FormStartPosition.CenterScreen;
               
            }


        }


    }
}
